﻿@{
    //page title
    ViewBag.Title = T("Admin.Catalog.Categories.Manage").Text;
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-catalog.png")" alt="" />
        @T("Admin.Catalog.Categories.Manage") @Html.ActionLink("(" + T("Admin.Catalog.Categories.SwitchToListView") + ")", "List")
    </div>
    <div class="options">
        <a href="@Url.Action("Create")" class="k-button">@T("Admin.Common.AddNew")</a>
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            <div id="category-treeview"></div>

            <script>
                categories = new kendo.data.HierarchicalDataSource({
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("TreeLoadChildren", "Category"))",
                            type: "POST",
                            dataType: "json"
                        }
                    },
                    schema: {
                        model: {
                            id: "id",
                            hasChildren: "hasChildren"
                        }
                    }
                });

                $(document).ready(function() {
                    $("#category-treeview").kendoTreeView({
                        dataSource: categories,
                        dataTextField: "Name",
                        select: function (e) {
                            var dataItem = this.dataItem(e.node);
                            var url = "@(Url.Action("Edit"))" + "/" + dataItem.id;
                            window.location = url;
                        }
                    });
                });

                
            </script>
        </td>
    </tr>
</table>
